#include <stdint.h>
#include <avr/io.h>
#include <avr/interrupt.h>
#include "dataIO.h"
#include "ringBuffer.h"

void timer2SoftSerialTransmitter_init(uint32_t baudRate);
void timer2SoftSerialTransmitter_write(char data);

class SoftSerialTransmitter : public DataOutput {
public:
	// What was done LAST time.
	static const uint8_t STARTBIT = 0;
	static const uint8_t DATABIT0 = 1;
	static const uint8_t DATABIT7 = 8;
	static const uint8_t STOPBIT  = 9;
	static const uint8_t STOPPED  = 10;

	SoftSerialTransmitter(uint32_t baudRate) {
		timer2SoftSerialTransmitter_init(baudRate);
	}

	/*
	void write(char data) {
		timer2SoftSerialTransmitter_write(data);
	}
	*/
	bool tryWrite(char data);
	size_t freeSpace();
};
